from get_file_name import get_name_by_ext
import ffmpeg


def cvt_ts2mp4(input_file, output_file):
    print(f"converting   {input_file}      -- to -->     {output_file}     ........")
    stream = ffmpeg.input(input_file)
    stream = ffmpeg.output(stream, output_file, vcodec='copy', acodec='copy')
    ffmpeg.run(stream)
    print("done!")
    print(" ")


def cvt_videos(file_list):
    for input_file in file_list:
        output_file = input_file.replace(".ts", ".mp4")
        cvt_ts2mp4(input_file, output_file)


def do_something():
    file_list = get_name_by_ext('D:\\workspace\\python\\get-all-files-in-directory', '*.ts')
    cvt_videos(file_list)


if __name__ == "__main__":
    do_something()